package com.frxuexi.repair.adapter

import androidx.databinding.DataBindingUtil
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.frxuexi.lib_base.entity.RepairBeanItem
import com.frxuexi.repair.R
import com.frxuexi.repair.databinding.ItemRepairBinding

class RepairAdapter:BaseQuickAdapter<RepairBeanItem,BaseViewHolder>(R.layout.item_repair) {

    override fun onItemViewHolderCreated(viewHolder: BaseViewHolder, viewType: Int) {
        super.onItemViewHolderCreated(viewHolder, viewType)
        DataBindingUtil.bind<ItemRepairBinding>(viewHolder.itemView)
    }

    override fun convert(helper: BaseViewHolder, item: RepairBeanItem) {
        val binding = DataBindingUtil.getBinding<ItemRepairBinding>(helper.itemView)!!
        binding.bean=item

        binding.repairStatus.apply {
            when(item.processingStatus){
                "待处理"->{
                    setTextColor(context.getColor(com.frxuexi.lib_base.R.color.darkorange))
                    setBackgroundResource(com.frxuexi.lib_base.R.drawable.shape_weihu)
                }
                "处理中"->{
                    setTextColor(context.getColor(com.frxuexi.lib_base.R.color.blue))
                    setBackgroundResource(com.frxuexi.lib_base.R.drawable.shape_zhanyong)
                }
                "已完成"->{
                    setTextColor(context.getColor(com.frxuexi.lib_base.R.color.green))
                    setBackgroundResource(com.frxuexi.lib_base.R.drawable.shape_status)
                }
            }
        }
    }
}